﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Registration.ascx.cs" Inherits="Shop.Web.Controls.Registration" %>
<asp:PlaceHolder runat="server" id="phFirstStep">
<script type="text/javascript">
</script>
<table id="registration">
        <tr>
            <td>E-mail</td>
            <td><asp:TextBox runat="server" id="tbEmail" MaxLength="50" SkinID="Email" OnBlur="SendMsgToAdmin(this)"></asp:TextBox></td>
            <td></td>
        </tr>
        <asp:PlaceHolder runat="server" id="phPasswrd">
        <tr>
            <td>Пароль</td>
            <td><asp:TextBox runat="server" id="tbPasswrd" TextMode="Password" SkinID="Required" MaxLength="50"></asp:TextBox></td>
            <td></td>
        </tr>
        <tr>
            <td>Подтвердите пароль</td>
            <td><asp:TextBox runat="server" id="tbPasswrdDouble" TextMode="Password" SkinID="Required" MaxLength="50"></asp:TextBox></td>
            <td></td>
        </tr>
        </asp:PlaceHolder>
        <tr>
            <td>Имя</td>
            <td><asp:TextBox runat="server" id="tbFirstName" MaxLength="150" SkinID="Required"></asp:TextBox></td>
            <td></td>
        </tr>
        <tr>
            <td>Фамилия</td>
            <td><asp:TextBox runat="server" id="tbLastName" MaxLength="150" SkinID="popup"></asp:TextBox></td>
            <td></td>
        </tr>
        <tr>
            <td>Пол</td>
            <td> 
                <input type="radio" name="sex" Checked="Checked" value="1" id="sex1"/> Женский &nbsp;
                <input type="radio" name="sex" value="0" id="sex0"/> Мужской
            <td></td>
        </tr>
        <tr>
            <td>Контактный телефон</td>
            <td><asp:TextBox runat="server" id="tbPhone" MaxLength="20" SkinID="popup"></asp:TextBox></td>
            <td></td>
        </tr>
        </table>
        <script type="text/javascript">
        function Save()
        {
          if (Valid($('#<%=tbEmail.ClientID %>')) &&  
                Valid($('#<%=tbPasswrd.ClientID %>')) && 
                Valid($('#<%=tbPasswrdDouble.ClientID %>'))&& 
                Valid($('#<%=tbFirstName.ClientID %>')))
          {
          HideError();
          $.post("AjaxHtmlContent.aspx?Content=CustomerAdd", 
                   {    email   : $('#<%=tbEmail.ClientID %>').val(),
                        passwrd : $('#<%=tbPasswrd.ClientID %>').val(),
                        name    : $('#<%=tbFirstName.ClientID %>').val(),
                        lastName: $('#<%=tbLastName.ClientID %>').val(),
                        phone   : $('#<%=tbPhone.ClientID %>').val(),
                        sex     : getRadioGroupValue()
                    }, 
                   function(data){
                   $('#<%=tbEmail.ClientID %>').val("");
                   $('#<%=tbPasswrd.ClientID %>').val("");
                   $('#<%=tbPasswrdDouble.ClientID %>').val("");
                   $('#<%=tbFirstName.ClientID %>').val("");
                   $('#<%=tbLastName.ClientID %>').val("");
                   $('#<%=tbPhone.ClientID %>').val("");
                   $(".dialog").dialog('close');
                   $(".required").each(function() { SetValid($(this)) });
                   $(".login").html(data);
                   } 
                   );}
                   else
                   {
                    Error("Заполните все поля корректно");
                   }
        }
        function getRadioGroupValue()
        {
            radioGroupObj = document.getElementsByName("sex");
            for (var i=0; i < radioGroupObj.length; i++)
                if (radioGroupObj[i].checked) 
                {
                    return radioGroupObj[i].value;
                }
            return null;
        }

        function SendMsgToAdmin(txt) {

            if (txt != "") {
                $.post("AjaxHtmlContent.aspx?Content=SendMsgToAdmin",
                    { email: $(txt).val() },
                    function(data) {
                    });
            }

        }
        </script>
</asp:PlaceHolder>
